package com.kly.user.controller;

import com.fqgj.common.api.Response;
import com.kly.user.dto.UserAccessDto;
import com.kly.user.dto.UserBaseDto;
import com.kly.user.dto.UserLoginDto;
import com.kly.user.enums.UserTokenType;
import com.kly.user.service.AuthLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试接口不对外开发
 */
@RestController
@RequestMapping("auth")
public class authController {

    @Autowired
    AuthLoginService authLogin;


    @ResponseBody
    @RequestMapping(value = "/authLogin")
    public Response<UserBaseDto> authLogin(@RequestBody UserLoginDto userLogin) {
        return authLogin.authLogin(userLogin);
    }

    @ResponseBody
    @RequestMapping(value = "/logout")
    public Response logout(String userCode) {
        return authLogin.logout(userCode);
    }

    @ResponseBody
    @RequestMapping(value = "/getToKen")
    public Response getToKen(String userCode) {
        return authLogin.getToKen(userCode, UserTokenType.SYSTEM_TOKEN);
    }

    @ResponseBody
    @RequestMapping(value = "/saveToken")
    public Response saveToken(@RequestBody UserAccessDto userAccessDto) {
        return authLogin.saveToken(userAccessDto, UserTokenType.SYSTEM_TOKEN);
    }

    @ResponseBody
    @RequestMapping(value = "/getRongCloudToken")
    public Response getRongCloudToken(String userCode) {
        return authLogin.getRongCloudToken(userCode);
    }

    @ResponseBody
    @RequestMapping(value = "/saveRongCloudToken")
    public void saveRongCloudToken(@RequestBody UserAccessDto userAccessDto) {
        authLogin.saveRongCloudToken(userAccessDto);
    }
}
